// 引入接口
import {roleList} from '@/request/api'

// 封装一个接口类型
interface StateRole{
    rolelist:Array<object>
}

const state={
    rolelist:[]
}

const getters={
    getRole(state:StateRole){
        return state.rolelist
    }
}

const mutations={
    REQ_ROLELIST(state:StateRole,payload:any){
        state.rolelist=payload
    }
}

const actions={
    getRoleAction(context:any){
        // 调用列表接口
        roleList().then(res=>{
            context.commit('REQ_ROLELIST',res.list)  
        })
    }
}

export default{
    state,
    getters,
    mutations,
    actions,
    // 命名空间
    namespaced:true
}